<template>
  <div class="home-wrap long-page ">
    <div class="child">
      <h1>home</h1>
      <div class="left-cont">
        <el-row>
          <el-button>默认按钮</el-button>
          <el-button type="primary">主要按钮</el-button>
          <el-button type="success">成功按钮</el-button>
          <el-button type="info">信息按钮</el-button>
          <el-button type="warning">警告按钮</el-button>
          <el-button type="danger">危险按钮</el-button>
        </el-row>
        <el-row>
          <el-button icon="el-icon-search"
            circle></el-button>
          <el-button type="primary"
            icon="el-icon-edit"
            circle></el-button>
          <el-button type="success"
            icon="el-icon-check"
            circle></el-button>
          <el-button type="info"
            icon="el-icon-message"
            circle></el-button>
          <el-button type="warning"
            icon="el-icon-star-off"
            circle></el-button>
          <el-button type="danger"
            icon="el-icon-delete"
            circle></el-button>
        </el-row>
      </div>
      <div>
        <el-button :plain="true"
          @click="open2">成功</el-button>
        <el-button :plain="true"
          @click="open3">警告</el-button>
        <el-button :plain="true"
          @click="open1">消息</el-button>
        <el-button :plain="true"
          @click="open4">错误</el-button>
      </div>
      <div>
        <el-input placeholder="请输入内容"
          v-model="input"
          :disabled="true">
        </el-input>
      </div>
      <div>
        修改主题色
        <ThemePicker />
      </div>
      <div class="coloricon">
        <div class="coloricon-item">
          <h2>颜色选择器</h2>
          <div class="color-picker-box">
            <ColorPicker @colorChange="colorPickerChange" />
            <!-- <ColorPicker initColor="#FFBF00"
            @colorChange="colorPickerChange" /> -->
          </div>
        </div>
        <div class="coloricon-item">
          <h2>图标选择器</h2>
          <div class="icon-picker-box">
            <IconPicker v-model="iconName" />
          </div>
        </div>
      </div>
      <div class="upload-demo">
        <div class="v-gap">el-upload是默认自动上传，多个文件请求多次</div>
        <el-upload ref="upload"
          action="http://119.13.208.104:8080/dzdt-server/sys/upload/uploadFile"
          :file-list="fileListx"
          :accept="uploadAccept"
          :on-remove="uploadRemove"
          :on-change="uploadChange"
          multiple
          :limit="uploadLimit">
          <el-button size="small"
            type="primary">点击上传</el-button>
        </el-upload>

        <div class="v-gap">一次请求传多个的形式（需要后台接口配合）</div>
        <el-upload ref="upload"
          action=""
          :accept="uploadAccept"
          :auto-upload="false"
          :on-remove="uploadRemove"
          :on-change="uploadChange"
          multiple
          :limit="uploadLimit">
          <el-button size="small"
            type="primary">点击上传</el-button>
        </el-upload>
        <div class="v-gap">
          <el-button :loading="uploadLoading"
            type="primary"
            size="small"
            @click="submitUpload">提交上传</el-button>
        </div>
      </div>
    </div>
    <div class="child">

    </div>

  </div>
</template>

<script>
  import ThemePicker from '@/components/theme-picker/index.vue';
  import ColorPicker from '@/components/color-picker/index.vue';
  import IconPicker from '@/components/icon-picker/index.vue';
  import { uploadMultFile } from '@/api/module/systemApi.js';

  export default {
    components: {
      ThemePicker,
      ColorPicker,
      IconPicker
    },
    data() {
      return {
        input: '',
        color: '#409EFF',
        iconName: {},
        // 会在本地找包含这些后缀的文件
        // uploadAccept: '.pdf,.docx,.doc',
        uploadAccept: '',
        // 文件超出这个数，自动上传不会执行
        uploadLimit: 2,
        fileList: [],
        fileListx: [],
        uploadLoading: false
      };
    },
    methods: {
      open1() {
        this.$message('这是一条消息提示');
      },
      open2() {
        this.$message({
          message: '恭喜你，这是一条成功消息',
          type: 'success'
        });
      },

      open3() {
        this.$message({
          message: '警告哦，这是一条警告消息',
          type: 'warning'
        });
      },

      open4() {
        this.$message.error('错了哦，这是一条错误消息');
      },
      colorPickerChange(val) {
        console.log('colorPickerChange', val);
      },
      uploadRemove(file, fileList) {
        this.fileList = fileList.map((item) => item.raw);
      },
      uploadChange(file, fileList) {
        this.fileList = fileList.map((item) => item.raw);
      },
      submitUpload() {
        this.uploadLoading = true;
        uploadMultFile({ file: this.fileList })
          .then((res) => {})
          .finally((this.uploadLoading = false));
      }
    }
  };
</script>

<style lang="scss" scoped>
  .home-wrap {
    display: flex;
    .child {
      flex: 1;
      width: 50%;
      padding: 20px 20px 0 20px;
      box-sizing: border-box;
    }
    .color-picker-box {
      // min-width: 315px;
      width: 320px;
      padding: 10px;
      box-sizing: border-box;
      border: 1px solid $--border-color;
    }
    .coloricon-item {
      display: inline-block;
      vertical-align: text-top;
      width: 400px;
      margin-right: 20px;
      .icon-picker-box {
        width: 100px;
      }
    }
    .upload-demo {
      margin-top: 10px;
    }
    .v-gap {
      margin: 10px 0;
    }
  }
</style>
